function rankings = mergeRankings(oFile, espnFile)

rankings = parseRankings(oFile);
rankings.newRank = rankings.rank;
espnRankings = parseESPN(espnFile);
crCount = 0;

for i=1:length(rankings.name)
    found = 0;
    if rankings.pos(i) == 6
        rname = regexprep(translateDSTName(rankings.name{i}),'[\W]','');
    else
        rname = regexprep(rankings.name{i},'[\W]','');
    end

    for j=1:length(espnRankings.name)
        ename = regexprep(espnRankings.name{j},'[\W]','');
        if strcmpi(rname,ename) && ...
            rankings.pos(i) == espnRankings.pos(j) && ...
            strcmpi(strtrim(rankings.team{i}), strtrim(espnRankings.team{j}))
            fprintf('.');
            crCount = crCount + 1;
            if crCount > 60
                fprintf('\n');
                crCount = 0;
            end
            rankings.newRank(i) = espnRankings.rank(j);
            found = 1;
            break;
        end
        
        
    end
    if ~found
        fprintf('\n%d: No match for %s\n',i,rankings.name{i});
    end
end

end

function tname = translateDSTName(name)
    s = regexp(name,' ','split');
    tname = sprintf('%s D/ST',s{end});
end
            
